import ComponentBase from "../engine/ComponentBase";

import { RoomModel } from "../game/model/RoomModel";
import { UserModel } from "../game/model/UserModel";
import { UIHelper } from "../game/util/UIHelper";
import MjPrefab from "./MjPrefab";

const { ccclass, property } = cc._decorator;

@ccclass
export default class WaiguaPrefab extends ComponentBase {


    private btnChangeMj: cc.Node
    private btnToushi: cc.Node
    private changeMjPrefab: cc.Node
    private isToushing:boolean = false

    onEnable(): void {
        super.onEnable();
        this.changeMjPrefab = this.findChild(this.node, "changeMjPrefab")
        this.changeMjPrefab.active = false

        this.btnChangeMj = this.findChild(this.node, "btnChangeMj")
        this.btnChangeMj.active = false
        if (UserModel.instance.waigua_mopai && !RoomModel.instance.isPlayVideo) {
            this.btnChangeMj.active = true
            UIHelper.onAddEvent(this.btnChangeMj, () => {
                this.changeMjPrefab.active = true
            })
        }
        this.btnToushi = this.findChild(this.node, "btnToushi")
        this.btnToushi.active = false
        if (UserModel.instance.waigua_toushi && !RoomModel.instance.isPlayVideo) {
            this.btnToushi.active = true
            UIHelper.onAddEvent(this.btnToushi, () => {
                this.isToushing = !this.isToushing
                // if (RoomModel.instance.game_info instanceof huanghua_mj_GameInfo) {
                //     if(this.isToushing){
                //         huanghua_mj_Gamemanager.instance.handMjContainer.initHandMj(1)
                //     }else{
                //         huanghua_mj_Gamemanager.instance.handMjContainer.initHandMj(2)
                //     }
                // }
                // else if(RoomModel.instance.game_info instanceof cangxian_mj_GameInfo){
                //     if(this.isToushing){
                //         cangxian_mj_Gamemanager.instance.handMjContainer.initHandMj(1)
                //     }else{
                //         cangxian_mj_Gamemanager.instance.handMjContainer.initHandMj(2)
                //     }
                // }
                // else if(RoomModel.instance.game_info instanceof dazhonger_mj_GameInfo){
                //     if(this.isToushing){
                //         dazhonger_mj_Gamemanager.instance.handMjContainer.initHandMj(1)
                //     }else{
                //         dazhonger_mj_Gamemanager.instance.handMjContainer.initHandMj(2)
                //     }
                // }
            })
        }
    }





}
